﻿<UserControl x:Class="AesonIntegrationTestModul.Views.IntegrationTestView"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
             xmlns:prism="clr-namespace:Microsoft.Practices.Prism.Mvvm;assembly=Microsoft.Practices.Prism.Mvvm.Desktop"
             xmlns:dataModel="clr-namespace:AesonIntegrationTestLibrary.DataModel;assembly=AesonIntegrationTestLibrary"
             prism:ViewModelLocator.AutoWireViewModel="True"
             xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"
             xmlns:p="http://www.codeplex.com/prism"
             xmlns:view="clr-namespace:AesonIntegrationTestModul.Views.TestDetails"
             xmlns:aesonPopup="clr-namespace:AesonXamlControls.Interaction.AesonPopup;assembly=AesonXamlControls"
             mc:Ignorable="d" 
             d:DesignHeight="300" d:DesignWidth="300">
    <i:Interaction.Triggers>
        <p:InteractionRequestTrigger SourceObject="{Binding ShowDetailRequest, Mode=TwoWay}" >
            <aesonPopup:AesonPopupAction IsModal="True" CenterOverAssociatedObject="True" >
                <aesonPopup:AesonPopupAction.WindowContent>
                   <view:TestDetailsView/> 
                </aesonPopup:AesonPopupAction.WindowContent>
            </aesonPopup:AesonPopupAction>
        </p:InteractionRequestTrigger>
    </i:Interaction.Triggers>

    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" ></RowDefinition>
            <RowDefinition Height="10*" ></RowDefinition>
        </Grid.RowDefinitions>
        <StackPanel Orientation="Horizontal">
            <Button Command="{Binding InitializeDatabaseCommand}" Margin="5" >Initialize Database</Button>
            <Label Content="{Binding Statut, Mode=TwoWay}" ></Label>
        </StackPanel>
        <ListView Grid.Row="1"  ItemsSource="{Binding Path=Tests,Mode=TwoWay}" SelectedItem="{Binding SelectedTest, Mode=TwoWay}" >
            <i:Interaction.Triggers  >
                <i:EventTrigger EventName="MouseDoubleClick" >
                    <i:InvokeCommandAction Command="{Binding ShowDetailCommand}" />
                </i:EventTrigger>
            </i:Interaction.Triggers>
            <ListView.ItemTemplate>
                <DataTemplate>
                    <StackPanel Orientation="Horizontal" Name="StackPanel"  >
                        <TextBlock Text="Methode : " ></TextBlock>
                        <TextBlock Text="{Binding Path=Method}" ></TextBlock>
                        <TextBlock Text="       " ></TextBlock>
                        <TextBlock Text="Statut : " ></TextBlock>
                        <TextBlock Text="{Binding Path=Statut}" ></TextBlock>
                        <TextBlock Text="       " ></TextBlock>
                        <TextBlock Text="Resultat  : " ></TextBlock>
                        <TextBlock Text="{Binding Path=Passed}" ></TextBlock>
                        <TextBlock Text="       " ></TextBlock>
                        <TextBlock Text="Temp necessaire  : " ></TextBlock>
                        <TextBlock Text="{Binding Path=Duration}" ></TextBlock>
                        <TextBlock Text="       " ></TextBlock>
                        <TextBlock Text="Message : " ></TextBlock>
                        <TextBlock Text="{Binding Path=Message}" ></TextBlock>
                        <TextBlock Text="       " ></TextBlock>
                        <TextBlock Text="Nombre : " ></TextBlock>
                        <TextBlock Text="{Binding Path=MessageCount}" ></TextBlock>
                        <TextBlock Text="       " ></TextBlock>
                    </StackPanel>
                    <DataTemplate.Triggers>
                        <DataTrigger Binding="{Binding Path=DataContext.Statut, RelativeSource={RelativeSource TemplatedParent}}" Value="Failed" >
                            <Setter Property="Background" TargetName="StackPanel" Value="Red"></Setter>
                        </DataTrigger>
                        <DataTrigger Binding="{Binding Path=DataContext.Statut, RelativeSource={RelativeSource TemplatedParent}}" Value="Passed" >
                            <Setter Property="Background" TargetName="StackPanel" Value="Green"></Setter>
                        </DataTrigger>
                    </DataTemplate.Triggers>
                </DataTemplate>

            </ListView.ItemTemplate>
        </ListView>

    </Grid>
</UserControl>
